package com.lovo.aspect;

import lombok.extern.slf4j.Slf4j;
import org.aopalliance.intercept.Joinpoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

/**
 * @title
 * @author: luo
 * @date: 2020/11/17 11:45
 */
@Aspect
@Component
@Slf4j(topic = "test")
public class UserAspect {
    @Pointcut("execution(* com.lovo.service..*(..))")
    public void logPointcut(){}

    @Around("logPointcut()")
    public Object computedTime(ProceedingJoinPoint joinPoint) throws Throwable {
//        long before = System.currentTimeMillis();
        Object ret = null;
        try {

            ret = joinPoint.proceed(joinPoint.getArgs());

        } catch (Throwable throwable) {
            throwable.printStackTrace();
            log.debug("抛出异常："+throwable.getMessage());
            throw throwable;
        }
        return ret;
    }


}
